<?php
/*
 * Created Febuary 27, 2008
 * @Author Taylor
 */
include_once(dirname(__FILE__).'/../database/dbPersons.php');
class testdbPersons extends UnitTestCase {
      function testdbPersonsModule() {
//add a manager
$m = new Person("Taylor", "Talmage", "928 Smith Union", "Brunswick", "ME", "04011",
2074415902, 2072654046,"ttalmage@bowdoin.edu","volunteer","","","","", "", "", "", "",
"Mon9-12,Tue9-12","","",
"02-19-89", "03-14-08","","","","Taylor2074415902");
$this->assertTrue(add_person($m));

//add an applicant
$a = new Person("Adam", "Talmage", "928 Smith Union", "Brunswick", "Maine", "04011",
2074415902, 2072654046,"ttalmage@bowdoin.edu","applicant,sub","","","","", "", "", "", "",
"Mon9-12,Tue9-12","","",
"02-19-89", "03-14-08", "I am availble","here I","am","Adam2074415902");
$this->assertTrue(add_person($a));

//add a guest chef
$c = new Person("Brian", "Talmage", "928 Smith Union", "Brunswick", "Maine", "04011",
2074415902, 2072654046,"ttalmage@bowdoin.edu","guestchef","","","","", "", "", "", "",
"Mon9-12,Tue9-12","","",
"02-19-89", "03-14-08","","","","Brian2074415902" );
$this->assertTrue(add_person($c));

//add a sub
$s = new Person("Chris", "Talmage", "928 Smith Union", "Brunswick", "Maine", "04011",
2074415902, 2072654046,"ttalmage@bowdoin.edu","sub","","","","", "", "", "", "",
"Mon9-12,Tue9-12","","",
"02-19-89", "03-14-08","","","","Chris2074415902" );
$this->assertTrue(add_person($s));

//add a volunteer
$v = new Person("David", "Talmage", "928 Smith Union", "Brunswick", "Maine",
"04011", 2074415902, 2072654046,"ttalmage@bowdoin.edu","volunteer","","","","", "", "", "", "",
"Mon9-12,Tue9-12","","",
"02-19-89", "03-14-08","I am availble","here I","am","David2074415902" );
$this->assertTrue(add_person($v));

//try to add a duplicate - should return false
$v = new Person("David", "Talmage", "928 Smith Union", "Brunswick", "Maine",
"04011", 2074415902, 2072654046,"ttalmage@bowdoin.edu","manager","","","","", "", "", "", "",
"","","",
"02-19-89", "03-14-08","I am availble","here I","am","David2074415902" );
$this->assertFalse(add_person($v));

//get a person
$p = get_person("Taylor2074415902");
$this->assertTrue($p!==null);

//try to get a person who is not in the db
$this->assertFalse(get_person("Tim2074415902"));

//get a volunteer
$p = get_person("Brian2074415902");
$this->assertTrue($p!==null);

// get all volunteers available for Monday from 9-12
$a = getall_available("volunteer", "Mon", "9-12");
$this->assertTrue(count($a) == 1);

//remove all persons
$this->assertTrue(remove_person("Brian2074415902"));
$this->assertTrue(remove_person("Adam2074415902"));
$this->assertTrue(remove_person("Taylor2074415902"));
$this->assertTrue(remove_person("Chris2074415902"));
$this->assertTrue(remove_person("David2074415902"));

//try to remove a person who is not in the db - should not work
$this->assertFalse(remove_person("Brian2074415902"));

echo("testdbPersons complete");
      }
}


?>
